import { h, ref } from 'vue';
import { cloneDeep } from 'lodash-es';
import { FormSchema } from '@/components/Form';

export class State {
  public id = 0; // 主键
  public zone = ''; // Zone
  public sESSIONID = ''; // Session ID
  public dOMAIN = ''; // DOMAIN 

  constructor(state?: Partial<State>) {
    if (state) {
      Object.assign(this, state);
    }
  }
}

export function newState(state: State | Record<string, any> | null): State {
  if (state !== null) {
    if (state instanceof State) {
      return cloneDeep(state);
    }
    return new State(state);
  }
  return new State();
}

// 表单验证规则

// 表格搜索表单
export const schemas = ref<FormSchema[]>([
  {
    field: 'id',
    component: 'NInputNumber',
    label: '主键',
    componentProps: {
      placeholder: '请输入主键',
      onUpdateValue: (e: any) => {
        console.log(e);
      },
    },
  },
]);

// 表格列
export const columns = [
  {
    title: '主键',
    key: 'id',
    align: 'left',
    width: -1,
  },
  {
    title: 'Zone',
    key: 'zone',
    align: 'left',
    width: -1,
  },
  {
    title: 'Session ID',
    key: 'sESSIONID',
    align: 'left',
    width: -1,
  },
  {
    title: 'DOMAIN ',
    key: 'dOMAIN',
    align: 'left',
    width: -1,
  },
];